<?php

namespace app\admin\validate;

use think\Validate;

class Article extends Validate {

    /**
     * 规则定义
     * @var array
     */
    protected $rule = [
        'id'         => 'number',
        'page'       => 'number',
        'pageSize'   => 'number',
        'categoryId' => 'number',
        'parentId'   => 'number',
        'view'       => 'number',
        'sort'       => 'number',
        'title'      => 'require|min:2|max:32',
        'content'    => 'require',
        'name'       => 'require|min:2|max:10'
    ];

    /**
     * 提示信息定义
     * @var array
     */
    protected $message = [
        'id'         => 'ID类型为正整数',
        'page'       => '分页参数类型为正整数',
        'pageSize'   => '每页展示参数为正整数',
        'categoryId' => '栏目ID参数为正整数',
        'parentId'   => '父级ID参数有误!',
        'view'       => '浏览次数参数有误，必须输入数字！',
        'sort'       => '排序参数有误',
        'title'      => '请输入2-32位字符文章标题',
        'content'    => '请输入文章内容',
        'name'       => '请输入2-10位分类名称',
    ];

    /**
     * 场景定义
     * @var array
     */
    public $scene = [
        'articleOperateAjax'      => ['view', 'sort', 'title', 'content'],
        'categoryOperateAjax'     => ['parentId', 'name', 'sort'],
    ];
}